{{ $parts := slice site.Params.doks.docsRepo }}

{{ if (eq site.Params.doks.repoHost "GitHub") }}
{{ $parts = $parts | append "blob" site.Params.doks.docsRepoBranch }}
{{ else if (eq site.Params.doks.repoHost "Gitea") }}
{{ $parts = $parts | append "_edit" site.Params.doks.docsRepoBranch }}
{{ else if (eq site.Params.doks.repoHost "GitLab") }}
{{ $parts = $parts | append "-/blob" site.Params.doks.docsRepoBranch }}
{{ else if (eq site.Params.doks.repoHost "Bitbucket") }}
{{ $parts = $parts | append "src" site.Params.doks.docsRepoBranch }}
{{ else if (eq site.Params.doks.repoHost "BitbucketServer") }}
{{ $parts = $parts | append "browse" site.Params.doks.docsRepoBranch }}
{{ end }}

{{ if isset site.Params.doks "docsreposubpath" }}
{{ if not (eq site.Params.doks.docsRepoSubPath "") }}
{{ $parts = $parts | append site.Params.doks.docsRepoSubPath }}
{{ end }}
{{ end }}

{{ $filePath := replace .File.Path "\\" "/" }}

{{ $lang := "" }}
{{ if site.Params.doks.multilingualMode }}
{{ $lang = .Lang }}
{{ end }}

{{ $parts = $parts | append "content" $lang $filePath }}

{{ $url := delimit $parts "/" }}

<div class="edit-page">
  <a href="{{ $url }}">
    <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-edit-2">
      <path d="M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z"></path>
    </svg>
    {{ i18n "edit_page" }} {{ site.Params.doks.repoHost }}
  </a>
</div>
